function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(";", c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}

function getStatusString (status) {
    var str = new Array("未支付","进行中","已完成","已关闭");
    return str[status];
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date()
    exdate.setDate(exdate.getDate() + expiredays)
    document.cookie = c_name + "=" + escape(value) +
        ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
}

function checkCookie() {
    username = getCookie('username')
    if (username != null && username != "") {
        alert('Welcome again ' + username + '!')
    } else {
        username = prompt('Please enter your name:', "")
        if (username != null && username != "") {
            setCookie('username', username, 365)
        }
    }
}

function checkInput(hint,string) {
    if (string.length == 0) {
        alert(hint + ":空")
        return false;
    } else if (string.match(" ")) {
        alert(hint + ":不能包含空格")
        return false;
    } 
    return true;
}

function checkInputEnglish(hint,string) {
    var jgpattern = /^[A-Za-z0-9]+$/;
    if (string.length == 0) {
        alert(hint + ":空")
        return false;
    } else if (string.match(" ")) {
        alert(hint + ":不能包含空格")
        return false;
    } else if (!jgpattern.test(string)) {
        alert(hint + "-" + string + "：只能输入英文字母大小写以及数字")
        return false;
    }
    return true;
}

function checkInputNumber(hint,string) {
    var jgpattern = /^[0-9|.]+$/;
    if (string.length == 0) {
        alert(hint + ":空")
        return false;
    } else if (string.match(" ")) {
        alert(hint + ":不能包含空格")
        return false;
    } else if (!jgpattern.test(string)) {
        alert(hint + "-" + string + "：只能输入数字")
        return false;
    }
    return true;
}
var QueryString = function () {
  // This function is anonymous, is executed immediately and 
  // the return value is assigned to QueryString!
  var query_string = {};
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
        // If first entry with this name
    if (typeof query_string[pair[0]] === "undefined") {
      query_string[pair[0]] = decodeURIComponent(pair[1]);
        // If second entry with this name
    } else if (typeof query_string[pair[0]] === "string") {
      var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
      query_string[pair[0]] = arr;
        // If third or later entry with this name
    } else {
      query_string[pair[0]].push(decodeURIComponent(pair[1]));
    }
  } 
    return query_string;
}();